using System;
using System.Management;

namespace DisplayDemo
{
    public class HardwareHelper
    {
        public static string GetKey()
        {
            string disk = System.Environment.MachineName;
            string cpu = HardwareHelper.GetCpuSerialNumber();

            return disk + cpu;
        }

        private static string GetMachineName()
        {
            try
            {
                return System.Environment.MachineName;
            }
            catch { }

            return "MN";
        }

        private static string GetCpuSerialNumber()
        {
            try
            {
                ManagementObjectCollection moc = new ManagementClass("Win32_Processor").GetInstances();

                foreach (ManagementObject mo in moc)
                {
                    return mo.Properties["ProcessorId"].Value.ToString();
                }
            }
            catch { }

            return "CSN";
        }
    }
}
